<?php
/* -------------------------------------------------------------------------------------
* 	ID:						$Id: print_pdf.php 301 2013-09-23 10:47:26Z phone.mueller@googlemail.com $
* 	Letzter Stand:			$Revision: 301 $
* 	zuletzt geaendert von:	$Author: siekiera $
* 	Datum:					$Date: 2013-09-23 10:47:26 +0000 (Mon, 23 Sep 2013) $
*
* 	SEO:mercari by Siekiera Media
* 	http://www.seo-mercari.de
*
* 	Copyright (c) since 2011 SEO:mercari
* --------------------------------------------------------------------------------------
* 	based on:
* 	(c) 2000-2001 The Exchange Project  (earlier name of osCommerce)
* 	(c) 2002-2003 osCommerce - www.oscommerce.com
* 	(c) 2003     nextcommerce - www.nextcommerce.org
* 	(c) 2005     xt:Commerce - www.xt-commerce.com
*
* 	Released under the GNU General Public License
* ----------------------------------------------------------------------------------- */

include('includes/application_top.php');
require(DIR_WS_CLASSES.'fpdf/html_table.php');

$content_data = $db->db_query("SELECT
									content_id,
									content_title,
									content_heading,
									content_text,
									content_file
								FROM 
									".TABLE_CONTENT_MANAGER."
								WHERE 
									content_group='".(int)$_GET['content']."'
								AND 
									languages_id='".(int) $_SESSION['languages_id']."'");

$name = strtr(utf8_decode($content_data->fields['content_heading']), array(' ' => '_'));
$file_name = DIR_FS_CATALOG.'media/content/'.$name.'.pdf';
if (file_exists($file_name)) {
  header('Content-Type: application/pdf');
  header('Content-Disposition: attachment; filename="'.$name.'.pdf"');
  readfile($file_name);
  exit();
}

$name = utf8_decode($content_data->fields['content_heading']);
$name = str_replace(' ','-',$name).'.pdf';

$pdf = new PDF_HTML_Table('P','mm','A4');
$pdf->AddPage();
$pdf->SetFont('Arial','U',12);
$pdf->Cell(20,10, utf8_decode($content_data->fields['content_heading']));
$pdf->Ln(20);
$pdf->SetFont('Arial','',11);
if($content_data->fields['content_file'] !='') {
	ob_start();
	include (DIR_FS_CATALOG.'media/content/'.$content_data->fields['content_file']);
	$text = utf8_encode(ob_get_contents());
	ob_end_clean();
} else
	$text = stripslashes($content_data->fields['content_text']);

$text = utf8_decode($text);
$text = html_entity_decode($text);

$pdf->WriteHTML($text);

$pdf->Output($name,'D');
?>